package com.har.modules.business.controller;

import com.har.common.utils.PageUtils;
import com.har.common.utils.R;
import com.har.common.validator.ValidatorUtils;
import com.har.modules.business.entity.TFinanceProductEntity;
import com.har.modules.business.service.TFinanceProductService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 金融产品
 *
 * @author macwy
 * @email 
 * @date 2018-06-26 16:38:42
 */
@RestController
@RequestMapping("business/tfinanceproduct")
public class TFinanceProductController {
    @Autowired
    private TFinanceProductService tFinanceProductService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("business:tfinanceproduct:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tFinanceProductService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("business:tfinanceproduct:info")
    public R info(@PathVariable("id") Long id){
        TFinanceProductEntity tFinanceProduct = tFinanceProductService.selectById(id);

        return R.ok().put("tFinanceProduct", tFinanceProduct);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("business:tfinanceproduct:save")
    public R save(@RequestBody TFinanceProductEntity tFinanceProduct){
        tFinanceProductService.insert(tFinanceProduct);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("business:tfinanceproduct:update")
    public R update(@RequestBody TFinanceProductEntity tFinanceProduct){
        ValidatorUtils.validateEntity(tFinanceProduct);
        tFinanceProductService.updateAllColumnById(tFinanceProduct);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("business:tfinanceproduct:delete")
    public R delete(@RequestBody Long[] ids){
        tFinanceProductService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
